package com.aaa.marketresearch.android.data.domain;

import org.json.simple.JSONObject;

import java.io.Serializable;

/**
 * @author Nail
 */
public class Market implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer id;

    private String name;

    private String description;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String printJSON() {
        StringBuilder builder = new StringBuilder();

        builder.append("{\"id\":").append(this.id).append(",");
        builder.append("\"name\":\"").append(this.name).append("\",");
        builder.append("\"description\":\"").append(this.description).append("\"}");

        return builder.toString();
    }

    public void setWithJSONObject(JSONObject jObj) {
        Object obj;

        obj = jObj.get("id");
        if (obj != null) {
            this.id = ((Long)obj).intValue();
        }
        obj = jObj.get("name");
        if (obj != null) {
            this.name = (String)obj;
        }
        obj = jObj.get("description");
        if (obj != null) {
            this.description = (String)obj;
        }
    }

    public Market() {
        this.name = "";
        this.description = "";
    }

}